/**
 * Created by IntelliJ IDEA.
 *
 * @ProjectName leetcode
 * @Author Ding
 * @CreateTime 2022/9/3 22:47 星期六
 */
public class Main4 {
    public static void main(String[] args) {
        int n = 9;
//        System.err.println(isStrictlyPalindromic(n));
        for (int i = 4; i < 10000; i++) {
            System.err.println(isStrictlyPalindromic(i));
        }
    }

    public static boolean isStrictlyPalindromic(int n) {
        int temp;
        int b = n - 4;
        while (b >= 0) {
            temp = n;
            int thisB = b + 2;
            //
            StringBuilder sb = new StringBuilder();
            while (temp != 1) {
                sb.append(temp % thisB);
                temp /= thisB;
            }
            sb.append(temp);

            int lp = 0;
            int rp = sb.length()-1;

            while (lp < rp){
                if (sb.charAt(lp) != sb.charAt(rp)){
                    return false;
                }
                lp++;
                rp--;
            }
            //
            b--;
        }
        return true;
    }
}
